package com.Q05;

/**
 * @version v1.0.0 创建时间：2022/7/13 10:49
 */
public class Q05_02 {
    public String printBin(double num) {
        String ans = "0.";
        while (num != 0) {
            num *= 2.0;
            if (num >= 1.0) {
                ans += "1";
                num = num - 1.0;
            } else {
                ans += "0";
            }
            if (ans.length() > 32) return "ERROR";
        }
        return ans;
    }

    public static void main(String[] args) {
        new Q05_02().printBin(0.1);
    }
}
